package com.softserveinc.autorent.controller;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;

import com.softserveinc.autorent.model.CarClassEnum;
import com.softserveinc.autorent.model.CarColorEnum;
import com.softserveinc.autorent.model.CarStatusEnum;
import com.softserveinc.autorent.model.CarVendor;

@ManagedBean(name = "form")
// or @Named("form")
@SessionScoped
public class SelectForm {

	//
	private Integer yearOfBirth;

	public Integer getYearOfBirth() {
		return yearOfBirth;
	}

	public void setYearOfBirth(Integer newValue) {
		yearOfBirth = newValue;
	}

	private static Collection<SelectItem> years;
	static {
		years = new ArrayList<SelectItem>();
		// The first item is a "no selection" item
		years.add(new SelectItem(null, "Pick a year:", "", false, false, true));
		for (int i = 1980; i < 2013; ++i)
			years.add(new SelectItem(i));
	}

	public Collection<SelectItem> getYearItems() {
		return years;
	}

	///
	private String[] colors;

	public String[] getColors() {
		return colors;
	}

	public void setColors(String[] newValue) {
		colors = newValue;
	}

	public Collection<SelectItem> getColorItems() {

		return colorItems;
	}

	private static Collection<SelectItem> colorItems;

	static {

		colorItems = new ArrayList<SelectItem>();
		// The first item is a "no selection" item
		colorItems.add(new SelectItem(null, "Pick a color:", "", false, false, true));
		for (CarColorEnum m : CarColorEnum.values())
			colorItems.add(new SelectItem(m.name()));

	}
	///class
	private String[] classes;

	public String[] getClasses() {
		return classes;
	}

	public void setClasses(String[] newValue) {
		classes = newValue;
	}

	public Collection<SelectItem> getClassesItems() {

		return classesItems;
	}

	private static Collection<SelectItem> classesItems;

	static {

		classesItems = new ArrayList<SelectItem>();
		// The first item is a "no selection" item
		classesItems.add(new SelectItem(null, "Pick a class:", "", false, false, true));
		for (CarClassEnum m : CarClassEnum.values())
			classesItems.add(new SelectItem(m.name()));

	}
	///status
	private String[] status;

	public String[] getStatus() {
		return status;
	}

	public void setStatus(String[] newValue) {
		status = newValue;
	}

	public Collection<SelectItem> getStatusItems() {

		return statusItems;
	}

	private static Collection<SelectItem> statusItems;

	static {

		statusItems = new ArrayList<SelectItem>();
		// The first item is a "no selection" item
		statusItems.add(new SelectItem(null, "Pick a status:", "", false, false, true));
		for (CarStatusEnum m : CarStatusEnum.values())
			statusItems.add(new SelectItem(m.name()));

	}
	///model
	private String[] model;

	public String[] getModel() {
		return model;
	}

	public void setModel(String[] newValue) {
		model = newValue;
	}

	public Collection<SelectItem> getModelItems() {

		return modelItems;
	}

	private static Collection<SelectItem> modelItems;

	static {

		modelItems = new ArrayList<SelectItem>();
		// The first item is a "no selection" item
		modelItems.add(new SelectItem(null, "Pick a status:", "", false, false, true));
		
		for (CarStatusEnum m : CarStatusEnum.values())
			modelItems.add(new SelectItem(m.name()));

	}
	///vendor
	private String[] vendor;

	public String[] getVendor() {
		return vendor;
	}

	public void setVendor(String[] newValue) {
		vendor = newValue;
	}

	public Collection<SelectItem> getVendorItems() {

		return vendorItems;
	}

	private static Collection<SelectItem> vendorItems;

	static {

		vendorItems = new ArrayList<SelectItem>();
		// The first item is a "no selection" item
		vendorItems.add(new SelectItem(null, "Pick a status:", "", false, false, true));
		ArrayList<CarVendor> listVendor = (ArrayList<CarVendor>) new CarVendorMB().getList(); 
		for (CarVendor m : listVendor)
			vendorItems.add(new SelectItem(m.toString()));

	}

}
